package jp.co.sharp.android.parents.kidsguard.activity.setting.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;


import jp.co.sharp.android.parents.kidsguard.R;

public class BatterySurplusDlg extends Dialog {

    private OnEditSetListener mOnEditSetListener;
    private OnClearSetListener mOnClearSetListener;
    private BatterySurplusDlg mBatterySurplusDlg;

    public BatterySurplusDlg(@NonNull Context context) {
        super(context);
        this.mBatterySurplusDlg = this;
    }

    public BatterySurplusDlg(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        this.mBatterySurplusDlg = this;
    }

    protected BatterySurplusDlg(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        this.mBatterySurplusDlg = this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dlg_battery_surplus);

        TextView editContactPerson = (TextView)findViewById(R.id.editContactPerson);
        editContactPerson.setOnClickListener(new ListenerEdit());
        TextView clearContactPerson = (TextView)findViewById(R.id.clearContactPerson);
        clearContactPerson.setOnClickListener(new ListenerClear());
    }

    /**
     * 連络先を编集する
     */
    public interface OnEditSetListener {
        void onOperateSet();
    }

    /**
     * 連絡先を解除する
     */
    public interface OnClearSetListener {
        void onOperateSet();
    }

    /*
     * 对外公开方法让Activity实现
     */
    public void setOnEditSetListener(OnEditSetListener callBack) {
        mOnEditSetListener = callBack;
    }

    /*
     * 对外公开方法让Activity实现
     */
    public void setOnClearSetListener(OnClearSetListener callBack) {
        mOnClearSetListener = callBack;
    }

    class ListenerEdit implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            if (mOnEditSetListener != null) {
                mOnEditSetListener.onOperateSet();
            }
        }
    }
    class ListenerClear implements View.OnClickListener {

        @Override
        public void onClick(View view) {
            if (mOnClearSetListener != null) {
                mOnClearSetListener.onOperateSet();
            }
        }
    }
}




























